/**
 * progression-table.css
 * Style du tableau d'analyse de progression (VERSION DIVS + DRAG & DROP)
 * ✅ Responsive optimisé pour mobile
 */

/* ============================================
   📊 SECTION TABLEAU D'ANALYSE
   ============================================ */

.progression-analysis-section {
    width: 100%;
    max-width: min(850px, 95vw);
    margin: 0 auto;
    padding: 0 clamp(0.5rem, 2vw, 1rem);
    box-sizing: border-box;
}

.analysis-title {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 700;
    color: #333;
    margin-bottom: clamp(0.75rem, 2vw, 1rem);
    margin-top: clamp(1rem, 3vw, 1.5rem);
    text-align: center;
}

/* ============================================
   🎹 SÉLECTEUR DE TONALITÉ - DROPDOWN CUSTOM
   ============================================ */

.key-selector-container {
    margin-bottom: clamp(1rem, 3vw, 2rem);
    padding: 0;
    text-align: center;
}

.key-selector-label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    text-align: center;
}

/* Conteneur du bouton et dropdown */
.key-selector-banner {
    position: relative;
    display: inline-block;
    max-width: min(200px, 90vw);
    width: 100%;
}

/* Bouton du sélecteur */
.key-selector-button {
    width: 100%;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 2.5vw, 1rem);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    font-weight: 500;
    border: 2px solid #808000;
    border-radius: clamp(6px, 1vw, 8px);
    background: #FFFAEB;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    user-select: none;
    box-sizing: border-box;
}

.key-selector-button:hover {
    border-color: #6b6b00;
    background-color: #FFFAEB;
}

.key-selector-button:focus {
    outline: none;
    border-color: #808000;
    box-shadow: 0 0 0 3px rgba(128, 128, 0, 0.2);
}

/* Rotation de l'icône quand ouvert */
.key-selector-button.open .progression-dropdown-icon {
    transform: rotate(180deg);
}

/* Empêcher le scroll général - forcer overflow visible sur les conteneurs */
[data-mode="progressions"] .page-layout {
    overflow: visible !important;
}

.progression-analysis-section {
    overflow: visible !important;
}

.key-selector-container {
    overflow: visible !important;
}

/* Le dropdown garde position absolute (positionnement relatif au bouton) */
.key-selector-banner {
    position: relative;
    overflow: visible !important;
}

.key-selector-banner > .progression-dropdown {
    left: 0;
    right: 0;
    transform: translateX(0) translateY(-10px);
}

.key-selector-banner > .progression-dropdown.open {
    transform: translateX(0) translateY(0);
}

/* ============================================
   📊 GRILLE EN DIVS - PROGRESSION
   ============================================ */

.analysis-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: clamp(0.5rem, 1.5vw, 1rem) 0;
    width: 100%;
    box-sizing: border-box;
}

.progression-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(80px, 15vw, 120px), 1fr));
    gap: 0;
    max-width: min(800px, 100%);
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border: clamp(1.5px, 0.3vw, 3px) solid #808000;
    border-radius: clamp(8px, 1.5vw, 12px);
    overflow: hidden;
    box-sizing: border-box;
}

/* ============================================
   🎯 COLONNE D'ACCORD (wrapper draggable)
   ============================================ */

.chord-column-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: clamp(80px, 15vw, 100px);
    cursor: move;
    transition: all 0.2s ease;
    border-right: 1.5px solid #808000;
}

.chord-column-wrapper:last-child {
    border-right: none;
}

.chord-column-wrapper:hover {
    transform: translateY(-2px);
}

/* ============================================
   🎨 CELLULES (degree, chord, notes)
   ============================================ */

.chord-column-wrapper .degree-cell,
.chord-column-wrapper .chord-cell,
.chord-column-wrapper .notes-cell {
    padding: clamp(0.4rem, 2vw, 0.75rem) clamp(0.25rem, 1.5vw, 0.5rem);
    text-align: center;
    border-bottom: 1.5px solid #808000;
    box-sizing: border-box;
}

.chord-column-wrapper .notes-cell {
    border-bottom: none;
}

/* Cellule du degré */
.degree-cell {
    font-weight: 700;
    font-size: clamp(0.8rem, 2.5vw, 1.1rem);
    color: #333;
    background: #e0d5a0;
    position: relative;
}

.degree-cell-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
}

.degree-number {
    font-weight: 700;
    font-size: clamp(0.8rem, 2.5vw, 1.1rem);
    min-width: clamp(18px, 4vw, 24px);
    text-align: center;
}

/* Cellule de l'accord */
.chord-cell {
    color: #808000;
    font-size: clamp(0.65rem, 2vw, 0.95rem);
    font-weight: 500;
    background: white;
}

/* Cellule des notes */
.notes-cell {
    font-weight: 600;
    font-size: clamp(0.75rem, 2.5vw, 1.05rem);
    color: #333;
    background: #FFFAEB;
}

/* ============================================
   🗑️ BOUTON SUPPRESSION
   ============================================ */

.progression-remove-btn {
    position: absolute;
    top: 50%;
    right: clamp(0.15rem, 0.5vw, 0.25rem);
    transform: translateY(-50%);
    width: clamp(1.125rem, 3vw, 1.5rem);
    height: clamp(1.125rem, 3vw, 1.5rem);
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.6rem, 1.5vw, 0.7rem);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

/* Visible au hover sur desktop */
.chord-column-wrapper:hover .progression-remove-btn {
    opacity: 1;
}

.progression-remove-btn:hover {
    background: rgb(220, 53, 69);
    transform: translateY(-50%) scale(1.1);
}

.progression-remove-btn i {
    pointer-events: none;
}

/* ============================================
   🎯 DRAG & DROP VISUEL
   ============================================ */

.chord-column-wrapper.dragging {
    opacity: 0.5;
}

.chord-column-wrapper.drag-over {
    border: 2px dashed #808000;
    border-radius: 8px;
}

/* ============================================
   ⚠️ ACCORDS HORS GAMME
   ============================================ */

.out-of-key {
    opacity: 0.6;
    position: relative;
}

/* Fond légèrement grisé pour les accords hors gamme */
.degree-cell.out-of-key {
    background: #d5d5c0;
}

.chord-cell.out-of-key {
    background: #f5f5f5;
}

.notes-cell.out-of-key {
    background: #f5f0dc;
}

/* Label optionnel pour hors gamme */
.out-of-key-label {
    font-size: 0.75em;
    color: #666;
    font-weight: normal;
    font-style: italic;
    display: block;
    margin-top: 0.25rem;
}

/* ============================================
   📱 RESPONSIVE - MOBILE (≤768px)
   ============================================ */

@media (max-width: 768px) {
    .progression-analysis-section {
        max-width: 100vw;
        padding: 0 0.5rem;
    }
    
    .analysis-title {
        font-size: 1.15rem;
    }
    
    .key-selector-banner {
        max-width: 90vw;
    }
    
    .key-selector-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .analysis-table-container {
        padding: 0.5rem 0;
    }
    
    .progression-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        border-width: 2px;
        border-radius: 8px;
        max-width: 100%;
    }
    
    .chord-column-wrapper {
        min-width: 80px;
    }
    
    .chord-column-wrapper .degree-cell,
    .chord-column-wrapper .chord-cell,
    .chord-column-wrapper .notes-cell {
        padding: 0.4rem 0.2rem;
    }
    
    .degree-cell {
        font-size: 0.85rem;
    }
    
    .degree-number {
        font-size: 0.85rem;
        min-width: 18px;
    }
    
    .chord-cell {
        font-size: 0.7rem;
    }
    
    .notes-cell {
        font-size: 0.8rem;
    }
    
    /* Bouton toujours visible sur mobile */
    .progression-remove-btn {
        opacity: 1;
        width: 1.125rem;
        height: 1.125rem;
        font-size: 0.6rem;
        right: 0.15rem;
    }
    
    /* Désactiver le hover transform sur mobile */
    .chord-column-wrapper:hover {
        transform: none;
    }
}

/* ============================================
   📱 RESPONSIVE - TRÈS PETIT MOBILE (≤480px)
   ============================================ */

@media (max-width: 480px) {
    .progression-analysis-section {
        padding: 0 0.25rem;
    }
    
    .analysis-title {
        font-size: 1rem;
    }
    
    .key-selector-button {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .analysis-table-container {
        padding: 0.4rem 0;
    }
    
    .progression-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        border-width: 1.5px;
        border-radius: 6px;
    }
    
    .chord-column-wrapper {
        min-width: 70px;
    }
    
    .chord-column-wrapper .degree-cell,
    .chord-column-wrapper .chord-cell,
    .chord-column-wrapper .notes-cell {
        padding: 0.35rem 0.15rem;
    }
    
    .degree-cell {
        font-size: 0.75rem;
    }
    
    .degree-number {
        font-size: 0.75rem;
        min-width: 16px;
    }
    
    .chord-cell {
        font-size: 0.65rem;
    }
    
    .notes-cell {
        font-size: 0.7rem;
    }
    
    .progression-remove-btn {
        width: 1rem;
        height: 1rem;
        font-size: 0.55rem;
        right: 0.1rem;
    }
}

/* ============================================
   🖥️ RESPONSIVE - TABLETTE (768px - 1024px)
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .progression-analysis-section {
        max-width: 90vw;
    }
    
    .progression-grid-container {
        max-width: 700px;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .chord-column-wrapper .degree-cell,
    .chord-column-wrapper .chord-cell,
    .chord-column-wrapper .notes-cell {
        padding: 0.65rem 0.4rem;
    }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

.progression-remove-btn:focus-visible,
.chord-column-wrapper:focus-visible {
    outline: 3px solid #808000;
    outline-offset: 2px;
}

/* ============================================
   PRÉFÉRENCE MOUVEMENT RÉDUIT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .progression-remove-btn,
    .chord-column-wrapper {
        transition: none;
    }
    
    .progression-remove-btn:hover,
    .chord-column-wrapper:hover {
        transform: none;
    }
    
    .progression-remove-btn:hover {
        transform: translateY(-50%);
    }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .progression-remove-btn {
        display: none !important;
    }
}
